/**
 * Created by Forcs on 16/4/20.
 */

var Flavors = require('../models/Flavors');

var FlavorController = function () {
};

FlavorController.prototype.saveFlavor = function (req, res) {
  Flavors.$manager.insert(
    {
      id: req.body.id,
      name: req.body.name,
      biz: req.body.biz
    },
    { notifiedEvent: 'add.flavor'},
    function (err, result) {
      if (err) {
        res.json({
          code: 0,
          msg: err.toString()
        });
        return;
      }

      res.json({
        code: 1,
        msg: 'ok',
        result: result
      });
    }
  )
};

FlavorController.prototype.onRouting = function (router) {
  router.post('/save', this.saveFlavor);
};

module.exports = FlavorController;
